<?php

namespace app\api\controller\carbon\journalism;

use app\common\controller\Api;
use think\Db;

/**
 * 核算接口
 */
class Info extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 新闻资讯列表
     *
     */
    public function index($type_id)
    {
        $list = model('app\admin\model\carbon\journalism\Info')
            ->where("type", $type_id)
            ->paginate();
        $this->success('获取成功', $list);
    }

    /**
     * 活动详情
     *
     */
    public function activeInfo($id)
    {
        $active = model('app\admin\model\carbon\journalism\Info')
            ->where('id', $id)
            ->find();
        $this->success('获取成功', $active);
    }

    /**
     * 记录浏览
     *
     */
    public function activeLog($id)
    {
        model('app\admin\model\carbon\journalism\Log')->insert(["journalism_id" => $id, "user_id" => $this->auth->id, "create_time" => time()]);
        model('app\admin\model\carbon\journalism\Info')->where(["journalism_id" => $id])->setInc("num");
    }
}
